<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="get()">get请求</button>
    <button onclick="post()">post请求</button>
    <button onclick="deletes()">delete请求</button>
    <button onclick="jsonp()">jsonp请求</button>
<script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
<script>
    // 测试get接口
    function get(){
        $.ajax({
            type:'GET',
            url:'http://127.0.0.1/api/get',
            data:{name:'zs',age:18},
            success:(res)=>{
                console.log(res);
            }
        })
    }
    // 测试post接口
    function post(){
        $.ajax({
            type:'POST',
            url:'http://127.0.0.1/api/post',
            data:{book:'水浒传',author:'施耐庵'},
            success:(res)=>{
                console.log(res);
            }
        })
    }
    // 测试delete接口
    function deletes(){
        $.ajax({
            type:'DELETE',
            url:'http://127.0.0.1/api/delete',
            data:{book:'水浒传',author:'施耐庵'},
            success:(res)=>{
                console.log(res);
            }
        })
    }
    // 测试delete接口
    function jsonp(){
        $.ajax({
            type:'GET',
            url:'http://127.0.0.1/api/jsonp',
            dataType:'jsonp',
            success:(res)=>{
                console.log(res);
            }
        })
    }
</script>
</body>
</html>